package com.woniuxy.springmvc.controller;

import com.woniuxy.springmvc.bean.UserBean;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author linke
 * @version 1.0
 * @className: LoginController
 * @description: 用于页面登录的控制器
 * @date 2021/11/13 14:56
 */
public class LoginController implements Controller {
    @Override
    public ModelAndView handleRequest(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws Exception {
        //获取页面请求参数
        String loginName = httpServletRequest.getParameter("loginName");
        String password = httpServletRequest.getParameter("pwd");

        //Model 数据就有了
        UserBean userBean = new UserBean(12L,"小李飞刀","LiXun","123456");

        ModelAndView mv = new ModelAndView();
        mv.addObject("user",userBean);// 等同于 request.setAttribute("user",userBean)
        mv.setViewName("/main");
        return mv;

    }
}
